package mac10.util;

import java.util.ArrayList;

/*
 * only used in A*Normal
 */

@Deprecated
public class OpenList extends ArrayList<Node>{
	
	private static final long serialVersionUID = 1403038172480826332L;

	public Node removeMin()
	{
		if(this.isEmpty())
			return null;
		
		int minIndex = 0;
		int minf = this.get(minIndex).getF();
		for (int i = 1; i < this.size(); i++) {
			int f = this.get(i).getF();
			if (f < minf)
			{
//				System.out.println("removeMin: "+get(i)+ " f: "+f);
				minf = f;
				minIndex = i;
			}
		}
		return this.remove(minIndex);
	}

	public void updateNode(Node node) {
		int index = indexOf(node);
		get(index).updateFAndPredecessor(node.getF(), node.getPredecessor());
	}
}
